import { BizDict, type Entry } from "jmash-core";
import { procApi, type ProcReq, type ProcModel } from "xyvcard-workflow";
export class ProcBizDict extends BizDict {
  useValues(): Promise<Entry[]> {
    return new Promise((resolve, reject) => {
      procApi
        .findList(this.query as ProcReq)
        .then(({ data }) => {
          const items: ProcModel[] = data.results;
          // 清空 this.values 数组
          this.values.length = 0;
          this.values.push(
            ...items.map(
              (item) =>
                ({
                  key: item.processKey,
                  value: item.processName,
                }) as Entry,
            ),
          );
          resolve(this.values);
        })
        .catch(reject);
    });
  }
}
